﻿using Xunit.Sdk;

namespace Xunit
{
	public partial class Assert
	{
		/// <summary>
		/// Verifies that the condition is false.
		/// </summary>
		/// <param name="condition">The condition to be tested</param>
		/// <exception cref="FalseException">Thrown if the condition is not false</exception>
		public static void False(bool condition)
		{
			False((bool?)condition, null);
		}

		/// <summary>
		/// Verifies that the condition is false.
		/// </summary>
		/// <param name="condition">The condition to be tested</param>
		/// <exception cref="FalseException">Thrown if the condition is not false</exception>
		public static void False(bool? condition)
		{
			False(condition, null);
		}

		/// <summary>
		/// Verifies that the condition is false.
		/// </summary>
		/// <param name="condition">The condition to be tested</param>
		/// <param name="userMessage">The message to show when the condition is not false</param>
		/// <exception cref="FalseException">Thrown if the condition is not false</exception>
		public static void False(bool condition, string userMessage)
		{
			False((bool?)condition, userMessage);
		}

		/// <summary>
		/// Verifies that the condition is false.
		/// </summary>
		/// <param name="condition">The condition to be tested</param>
		/// <param name="userMessage">The message to show when the condition is not false</param>
		/// <exception cref="FalseException">Thrown if the condition is not false</exception>
		public static void False(bool? condition, string userMessage)
		{
			if (!condition.HasValue || condition.GetValueOrDefault())
				throw new FalseException(userMessage, condition);
		}

		/// <summary>
		/// Verifies that an expression is true.
		/// </summary>
		/// <param name="condition">The condition to be inspected</param>
		/// <exception cref="TrueException">Thrown when the condition is false</exception>
		public static void True(bool condition)
		{
			True((bool?)condition, null);
		}

		/// <summary>
		/// Verifies that an expression is true.
		/// </summary>
		/// <param name="condition">The condition to be inspected</param>
		/// <exception cref="TrueException">Thrown when the condition is false</exception>
		public static void True(bool? condition)
		{
			True(condition, null);
		}

		/// <summary>
		/// Verifies that an expression is true.
		/// </summary>
		/// <param name="condition">The condition to be inspected</param>
		/// <param name="userMessage">The message to be shown when the condition is false</param>
		/// <exception cref="TrueException">Thrown when the condition is false</exception>
		public static void True(bool condition, string userMessage)
		{
			True((bool?)condition, userMessage);
		}

		/// <summary>
		/// Verifies that an expression is true.
		/// </summary>
		/// <param name="condition">The condition to be inspected</param>
		/// <param name="userMessage">The message to be shown when the condition is false</param>
		/// <exception cref="TrueException">Thrown when the condition is false</exception>
		public static void True(bool? condition, string userMessage)
		{
			if (!condition.HasValue || !condition.GetValueOrDefault())
				throw new TrueException(userMessage, condition);
		}
	}
}